﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using XStudio.XCRF.Data.Entities;
using XStudio.XCRF.Web.Common.Sessions;
using XStudio.XCRF.Data.Enums;
using XStudio.XCRF.Data.Entities.LabCheck;
using XStudio.XCRF.Data.Entities.CureInfo;
using XStudio.XCRF.Data.Entities.BasicInfo;

namespace XStudio.XCRF.Web.Extensions
{
    public static class CRFExtensions
    {
        public static bool CanModify(this CRF crf)
        {
            if (LoginSession.MemberType == MemberTypes.Administrator)
                return true;
            if (LoginSession.HospitalID != crf.HospitalID)
                return false;
            if (LoginSession.MemberType == MemberTypes.Owner)
                return true;
            if (LoginSession.LoginID == crf.ResearcherID)
                return true;
            return false;
        }
        public static bool CanModify(this BasicInfo basicInfo)
        {
            return basicInfo.CRF.CanModify();
        }
        public static bool CanModify(this LabCheck labcheck)
        {
            return labcheck.CRF.CanModify();
        }
        public static bool CanModify(this CureInfo cureInfo)
        {
            return cureInfo.CRF.CanModify();
        }
    }
}